.class public Lcom/philzhu/www/framework/Pool;
.super Ljava/lang/Object;
.source "Pool.java"


# annotations
.annotation system Ldalvik/annotation/MemberClasses;
    value = {
        Lcom/philzhu/www/framework/Pool$PoolObjectFactory;
    }
.end annotation

.annotation system Ldalvik/annotation/Signature;
    value = {
        "<T:",
        "Ljava/lang/Object;",
        ">",
        "Ljava/lang/Object;"
    }
.end annotation


# instance fields
.field private final factory:Lcom/philzhu/www/framework/Pool$PoolObjectFactory;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Lcom/philzhu/www/framework/Pool$PoolObjectFactory",
            "<TT;>;"
        }
    .end annotation
.end field

.field private final freeObjects:Ljava/util/List;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Ljava/util/List",
            "<TT;>;"
        }
    .end annotation
.end field

.field private final maxSize:I


# direct methods
.method public constructor <init>(Lcom/philzhu/www/framework/Pool$PoolObjectFactory;I)V
    .locals 1
    .parameter
    .parameter "maxSize"
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(",
            "Lcom/philzhu/www/framework/Pool$PoolObjectFactory",
            "<TT;>;I)V"
        }
    .end annotation

    .prologue
    .line 15
    .local p0, this:Lcom/philzhu/www/framework/Pool;,"Lcom/philzhu/www/framework/Pool<TT;>;"
    .local p1, factory:Lcom/philzhu/www/framework/Pool$PoolObjectFactory;,"Lcom/philzhu/www/framework/Pool$PoolObjectFactory<TT;>;"
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 16
    iput-object p1, p0, Lcom/philzhu/www/framework/Pool;->factory:Lcom/philzhu/www/framework/Pool$PoolObjectFactory;

    .line 17
    iput p2, p0, Lcom/philzhu/www/framework/Pool;->maxSize:I

    .line 18
    new-instance v0, Ljava/util/ArrayList;

    invoke-direct {v0, p2}, Ljava/util/ArrayList;-><init>(I)V

    iput-object v0, p0, Lcom/philzhu/www/framework/Pool;->freeObjects:Ljava/util/List;

    .line 19
    return-void
.end method


# virtual methods
.method public free(Ljava/lang/Object;)V
    .locals 2
    .parameter
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(TT;)V"
        }
    .end annotation

    .prologue
    .line 33
    .local p0, this:Lcom/philzhu/www/framework/Pool;,"Lcom/philzhu/www/framework/Pool<TT;>;"
    .local p1, object:Ljava/lang/Object;,"TT;"
    iget-object v0, p0, Lcom/philzhu/www/framework/Pool;->freeObjects:Ljava/util/List;

    invoke-interface {v0}, Ljava/util/List;->size()I

    move-result v0

    iget v1, p0, Lcom/philzhu/www/framework/Pool;->maxSize:I

    if-ge v0, v1, :cond_0

    .line 34
    iget-object v0, p0, Lcom/philzhu/www/framework/Pool;->freeObjects:Ljava/util/List;

    invoke-interface {v0, p1}, Ljava/util/List;->add(Ljava/lang/Object;)Z

    .line 35
    :cond_0
    return-void
.end method

.method public newObject()Ljava/lang/Object;
    .locals 4
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "()TT;"
        }
    .end annotation

    .prologue
    .line 22
    .local p0, this:Lcom/philzhu/www/framework/Pool;,"Lcom/philzhu/www/framework/Pool<TT;>;"
    const/4 v0, 0x0

    .line 24
    .local v0, object:Ljava/lang/Object;,"TT;"
    iget-object v1, p0, Lcom/philzhu/www/framework/Pool;->freeObjects:Ljava/util/List;

    invoke-interface {v1}, Ljava/util/List;->size()I

    move-result v1

    if-nez v1, :cond_0

    .line 25
    iget-object v1, p0, Lcom/philzhu/www/framework/Pool;->factory:Lcom/philzhu/www/framework/Pool$PoolObjectFactory;

    invoke-interface {v1}, Lcom/philzhu/www/framework/Pool$PoolObjectFactory;->createObject()Ljava/lang/Object;

    move-result-object v0

    .line 29
    :goto_0
    return-object v0

    .line 27
    :cond_0
    iget-object v1, p0, Lcom/philzhu/www/framework/Pool;->freeObjects:Ljava/util/List;

    iget-object v2, p0, Lcom/philzhu/www/framework/Pool;->freeObjects:Ljava/util/List;

    invoke-interface {v2}, Ljava/util/List;->size()I

    move-result v2

    const/4 v3, 0x1

    sub-int/2addr v2, v3

    invoke-interface {v1, v2}, Ljava/util/List;->remove(I)Ljava/lang/Object;

    move-result-object v0

    goto :goto_0
.end method
